#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>

using namespace std;

//long long mincom(int x, int y) {
//    if (x == 1) return y;
//    int a = x, b = y;
//    long long ret = x * y;
//    for (int i = x; i >= 2; i /= 2) {
//        if (a % i == 0 && b % i == 0) {
//            ret /= (long long)i;
//            a /= i;
//            b /= i;
//        }
//    }
//    return ret;
//}
//
//int main() {
//    /*int a, b;
//    cin >> a >> b;
//    if (a > b) swap(a, b);*/
//    cout << mincom(99999, 100000);
//
//    return 0;
//}


//int MLS(vector<int>& arr) {
//    if (arr.size() == 1) return 1;
//    sort(arr.begin(), arr.end());
//    int st = 0, cur = 1, pre = 0, ret = 1;
//    while (cur < arr.size()) {
//        if (arr[cur] == arr[pre] + 1) pre = cur;
//        else if (arr[cur] != arr[pre] + 1 && arr[cur] != arr[pre]) {
//            ret = max(ret, arr[pre] - arr[st] + 1);
//            st = cur;
//            pre = cur;
//        }
//        ++cur;
//    }
//    ret = max(ret, arr[pre] - arr[st] + 1);
//    return ret;
//}
//
//int main()
//{
//    vector<int> arr{ 1,1,2,2,3,3,6,7,4,5 };
//    cout << MLS(arr);
//    return 0;
//}

int n, m;
int maxscore(vector<vector<int>> nums) {
    vector<vector<int>> dp(n+2, vector<int>(m+2, 0));
    for (int i = 1; i <= n; ++i) 
        for (int j = 1; j <= m; ++j) 
            dp[i][j] = dp[i][j - 1] + dp[i - 1][j] - dp[i - 1][j - 1] + nums[i][j];
        
    
    int ret = 0;
    int x = 1, y = 1;
    while ((x < n && y <= m) || (x <= n && y < m)) {
        ret += nums[x][y];
        int x1 = x + 1, y1 = y;
        int x2 = x, y2 = y + 1;
        int sum1 = dp[n][m] - dp[n][y1 - 1] - dp[x1 - 1][m] + dp[x1 - 1][y1 - 1];
        int sum2 = dp[n][m] - dp[n][y2 - 1] - dp[x2 - 1][m] + dp[x2 - 1][y2 - 1];
        if (sum1 > sum2) x = x1, y = y1;
        else if (sum1 < sum2) x = x2, y = y2;
        else {
            if(nums[x1][y1] > nums[x2][y2]) x = x1, y = y1;
            else x = x2, y = y2;
        }
    }
    if (x == n && y == m) ret += nums[n][m];
    return ret;
}

int main() {
 
    cin >> n >> m;
    vector<vector<int>> nums(n + 1, vector<int>(m + 1, 0));
    for (int i = 1; i < n + 1; ++i) {
        for (int j = 1; j < m + 1; j++) {
            char x;
            int s;
            cin >> x;
            if (x == 'l') s = 4;
            else if (x == 'o') s = 3;
            else if (x == 'v') s = 2;
            else if (x == 'e') s = 1;
            else s = 0;
            nums[i][j] = s;
        }
    }
    n = 2, m = 3;
    //vector<vector<int>> nums{ {0,0,0,0},{ 0,0,0,0 },{0,0,0,0},{0,1,0,0},{0,0,0,0} };
    //vector<vector<int>> nums{ {0,0,0,0,0},{ 0,4,4,1,0},{0,3,2,1,0},{0,0,0,0,0} };
    int ans = maxscore(nums);
    cout << ans;

    return 0;
}